
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta name="keywords" content="" />

<meta name="description" content="" />

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="js/jquery-latest.pack.js"></script>
</head>
<?php
	session_start();
	
	include_once "function.php";
?>



<body>

<div id="wrapper">

	<div id="wrapper2">

		<?php include_once 'header.php';?>



		<!-- end #header -->

		<div id="page">

			<div id="content">

				<div class="post">
				<div id='tabb'>
	<?php 			if(isset($_POST['submit'])) {
		if($_POST['username'] == "" || $_POST['password'] == "") {
			$login_error = "One or more fields are missing.";
		}
		else {
			$check = user_pass_check($_POST['username'],$_POST['password']); // Call functions from function.php
			if($check == 1) {
				$login_error = "User ".$_POST['username']." not found.";
			}
			elseif($check==2) {
				$login_error = "Incorrect password.";
			}
			else if($check==0){
				$_SESSION['username']=$_POST['username']; //Set the $_SESSION['username']
				$userid = getUserID($_POST['username']);
				
				$_SESSION['userid']=$userid;
				header("Location: browse.php");
			}		
		}
}


 
?>

	<form method="post" action="<?php echo "index.php"; ?>">

	<table width="100%" cellpadding="10" cellspacing="10">
		<tr>
			<td  width="15%">Username:</td>
			<td width="80%"><input class="text"  type="text" name="username"><br /></td>
		</tr>
		<tr>
			<td  width="15%">Password:</td>
			<td width="80%"><input class="text"  type="password" name="password"><br /></td>
		</tr>
		
        
		
		
	
		<tr>
			<td  width="19%"></td>
			<td><table >
			<td><input name="submit" class="button" type="submit" value="Login">
			<td><h5 >New User ?	</h5></td>
			<td><input name="register" type="button" class="button" onclick="window.location.href='Register.php'" value="Register"></input></td></table></td>
		</tr>
		</table>
		
	
	
	</form>

<?php
  if(isset($login_error))
   {  echo "<div id='passwd_result'>".$login_error."</div>";}
?>
				</div>		
				</div>
				</div>
			<!-- end #content -->

			<!-- end #sidebar -->

			<div style="clear: both;">&nbsp;</div>

		</div>

		<!-- end #page -->

		<div id="footer">

			<p>Copyright (c) 2011 Sitename.com. All rights reserved. Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>

		</div>

	</div>

</div>

<!-- end #footer -->

</body>

</html>

